//
//  YABaseTableViewController.swift
//  于昂微博
//
//  Created by 鱼龙之梦 on 15/8/31.
//  Copyright © 2015年 鱼龙之梦. All rights reserved.
//

import UIKit

class YABaseTableViewController: UITableViewController {
    var userLogin = YAUserAcountVM.sharedUserAccount.userLogon
    override func loadView() {
        userLogin ? super.loadView() : setupVistorView()
    }
    var visitView : VisitorLoginView?
    private func setupVistorView(){
        visitView = VisitorLoginView()
        view = visitView
       // visitView?.delegate = self
        view.backgroundColor = UIColor(white: 237.0/255.0, alpha: 1)
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        //MARK: - 在这里添加事件监听 为了用presentViewController方法
        visitView?.registerButton.addTarget(self, action: "visitorLoginViewWillRegister", forControlEvents: UIControlEvents.TouchUpInside)
        visitView?.loginButton.addTarget(self, action: "visitorLoginViewWillLogin", forControlEvents: UIControlEvents.TouchUpInside)
    }
    func visitorLoginViewWillLogin() {
        
        let vc = UINavigationController(rootViewController: YALoginController())
        presentViewController(vc, animated: true, completion: nil)
    }
    func visitorLoginViewWillRegister() {
        print("注册待续...")
    }
}
